#ifndef IMAGEPANEL_H
#define IMAGEPANEL_H

#include <QPaintEvent>
#include <QUndoStack>
#include "IImagePanel.h"

class ImagePanel : public IImagePanel
{
	Q_OBJECT
public:
	explicit ImagePanel(QWidget *parent = 0);
	~ImagePanel();
	void setImagePath(QString strFilepath);
	void setSelect(bool bSelect);
	void reset();

signals:
	void SignalSelected();
	void SignalDoubleClick();

public slots:
	void SlotWindowing(int width, int center);
	void SlotGamma(int gamma);
	void SlotSetTool(ETool eTool);
	void saveImage(bool bIsDiagnosis);

protected:
	void paintEvent(QPaintEvent *event);
	void mousePressEvent(QMouseEvent *event);
	void mouseMoveEvent(QMouseEvent *event);
	void mouseReleaseEvent(QMouseEvent *event);
	void resizeEvent(QResizeEvent *event);
	void dragEnterEvent(QDragEnterEvent *event);
	void dropEvent(QDropEvent *event);
	void mouseDoubleClickEvent(QMouseEvent *event);
	bool eventFilter(QObject *, QEvent *);

private:
	void cleanImage();
	void updateZoomRatio();
	void applyZoomRatio();
	void calcFitSize();
	void resetImage();
	void resetOverlay();

private:
	RawImage *m_pImage;
	QPoint m_ptStart;
	QPoint m_ptEnd;
	QList<IShape *> *m_pListShape;
	IShape* m_pShapeTemp;
	float m_fLastZoom;
	float m_fZoomRatio;
	bool m_bSelected;
	QUndoStack m_undoStack;
	float m_fPixelPitchH, m_fPixelPitchV;
};

#endif // IMAGEPANEL_H
